#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<math.h>

int main()
{
    int t = 0;
    scanf("%d", &t);
    long long n = 0;
    long long fn = 0;
    for (int i = 0; i < t; i++)
    {
        fn = 0;
        scanf("%lld", &n);
        while (n != 0)
        {
            if (n & 1)
            {
                fn++;
            }
            n >>= 1;
        }
        long long n_less = pow(2, fn) - 1;
        printf("%lld %lld\n", fn, n_less);
    }
    return 0;
}